next up previous contents index
Next: Constants Up: Data types Previous: Set types

Enumeration types

Enumeration types are supported in Free Pascal. On top of the Turbo Pascal implementation, Free Pascal allows the following C-style extension of the enumeration type.

Type
  EnumType = (one, two, three, forty := 40);
As a result, the ordinal number of forty is 40, and not 4, as it would be when the '= 40' wasn't present.

When specifying such an enumeration type, it is important to keep in mind that you should keep initialized set elements in ascending order. The following will produce a compiler error:

Type
  EnumType = (one, two, three, forty := 40, thirty:=30);
It is necessary to keep forty and Thirty in the correct order.

Remark : You cannot use the Pred and Succ functions on this kind of enumeration types. If you try to do that, you'll get a compiler error.



Michael Van Canneyt
Tue Mar 31 16:48:49 CEST 1998